package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaItemBigType;
import com.ruoyi.system.service.IJiajiaItemBigTypeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大项目类型Controller
 * 
 * @author ruoyi
 * @date 2025-02-20
 */
@Controller
@RequestMapping("/jiajia/itemBigType")
public class JiajiaItemBigTypeController extends BaseController
{
    private String prefix = "jiajia/itemBigType";

    @Autowired
    private IJiajiaItemBigTypeService jiajiaItemBigTypeService;

    @RequiresPermissions("jiajia:itemBigType:view")
    @GetMapping()
    public String itemBigType()
    {
        return prefix + "/itemBigType";
    }

    /**
     * 查询大项目类型列表
     */
    @RequiresPermissions("jiajia:itemBigType:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaItemBigType jiajiaItemBigType)
    {
        startPage();
        List<JiajiaItemBigType> list = jiajiaItemBigTypeService.selectJiajiaItemBigTypeList(jiajiaItemBigType);
        return getDataTable(list);
    }

    /**
     * 导出大项目类型列表
     */
    @RequiresPermissions("jiajia:itemBigType:export")
    @Log(title = "大项目类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaItemBigType jiajiaItemBigType)
    {
        List<JiajiaItemBigType> list = jiajiaItemBigTypeService.selectJiajiaItemBigTypeList(jiajiaItemBigType);
        ExcelUtil<JiajiaItemBigType> util = new ExcelUtil<JiajiaItemBigType>(JiajiaItemBigType.class);
        return util.exportExcel(list, "大项目类型数据");
    }

    /**
     * 新增大项目类型
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存大项目类型
     */
    @RequiresPermissions("jiajia:itemBigType:add")
    @Log(title = "大项目类型", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaItemBigType jiajiaItemBigType)
    {
        return toAjax(jiajiaItemBigTypeService.insertJiajiaItemBigType(jiajiaItemBigType));
    }

    /**
     * 修改大项目类型
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaItemBigType jiajiaItemBigType = jiajiaItemBigTypeService.selectJiajiaItemBigTypeById(id);
        mmap.put("jiajiaItemBigType", jiajiaItemBigType);
        return prefix + "/edit";
    }

    /**
     * 修改保存大项目类型
     */
    @RequiresPermissions("jiajia:itemBigType:edit")
    @Log(title = "大项目类型", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaItemBigType jiajiaItemBigType)
    {
        return toAjax(jiajiaItemBigTypeService.updateJiajiaItemBigType(jiajiaItemBigType));
    }

    /**
     * 删除大项目类型
     */
    @RequiresPermissions("jiajia:itemBigType:remove")
    @Log(title = "大项目类型", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaItemBigTypeService.deleteJiajiaItemBigTypeByIds(ids));
    }
}
